/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import Entities.TblRoles;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author CuongNV
 */
@ManagedBean
@RequestScoped
public class RoleManagedBean extends TblRoles {

    /** Creates a new instance of RoleManagedBean */
    public RoleManagedBean() {
    }
    private List<TblRoles> all;
    private TblRoles roleBean;

    public List<TblRoles> getAll() {
        return new BLL.RoleBLL().getAll();
    }

    public String add() {
        try {
            new BLL.RoleBLL().add(this.roleBean);
            return "rolelist";
        } catch (Exception ex) {
            Logger.getLogger(BranchManagedBean.class.getName()).log(Level.SEVERE, null, ex);
            return "null";
        }
    }

    public String update() {
        if (new BLL.RoleBLL().update(this.roleBean)) {
            return "rolelist";
        } else {
            return "null";
        }
    }

    public String delete() {
        if (new BLL.RoleBLL().update(this.roleBean)) {
            return "rolelist";
        } else {
            return "null";
        }
    }

    public TblRoles getRoleBean() {
        return roleBean;
    }

    public void setRoleBean(TblRoles roleBean) {
        this.roleBean = roleBean;
    }
}
